﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace CarLoanSystem.Comman
{
    public class AjaxScript
    {
        public static void AlertMsg(string Message,Page pge)
        {
            ScriptManager.RegisterStartupScript(pge, pge.GetType(), "err_msg", "alert('" + Message + "');", true);
        }

        public static void OpenNewWindow(string url, Page pge)
        {
            //ScriptManager.RegisterStartupScript(pge, pge.GetType(), "popup", "window.open('" & url & "', 'popup', 'height=' + screen.height + 'width=' + screen.width); ", True)
            ScriptManager.RegisterStartupScript(pge, pge.GetType(), "popup", "window.open('" + url + "'); ", true);
        }

        public static void ManualScript(string Script, Page pge)
        {
            //ScriptManager.RegisterStartupScript(pge, pge.GetType(), "popup", "window.open('" & url & "', 'popup', 'height=' + screen.height + 'width=' + screen.width); ", True)
            ScriptManager.RegisterStartupScript(pge, pge.GetType(), "func", Script, true);
        }

        public static void SelectAllText(System.Web.UI.WebControls.TextBox txt, Page pge)
        {
            AjaxScript.ManualScript(string.Format("document.getElementById('{0}').select();", txt.ClientID), pge);
        }
    }
}
